package mvc.Admin.Action.member;

import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import mvc.Model.member.MemberDTO;
import mvc.Model.member.MemberMgr;
import mvc.controller.Action;
import mvc.controller.ActionForward;

public class MemberUpdateAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request, HttpServletResponse response) throws Throwable {

		request.setCharacterEncoding("EUC-KR");

		MemberMgr mgr = new MemberMgr();
		
		String mode = request.getParameter("mode");
		request.setAttribute("mode", mode);
		System.out.println("mode : " + mode);
		
		int u_seq = Integer.parseInt(request.getParameter("u_seq"));

		MemberDTO dto = mgr.mem_info(u_seq);
		
		request.setAttribute("mdto", dto);
		
		String[] u_tel = dto.getU_tel().split("-");
		request.setAttribute("u_tel", u_tel);
		
		String[] u_mobile = dto.getU_mobile().split("-");
		request.setAttribute("u_mobile", u_mobile);

		String[] u_birth = dto.getU_birthday().substring(0,10).split("-");
		request.setAttribute("u_birth", u_birth);

		ActionForward forward = new ActionForward();
		forward.setRedirect(false);
		forward.setPath("/_AdMin/Member/Member_Update.tiles");
		return forward;
	}

}
